<template>
  <div>
    <el-container>
      <el-header>
        <div class="header-left">
          <!-- 头部左侧 -->
          <img
            src="https://www.escook.cn/vue-shop/img/heima.b5a855ee.png"
            alt=""
          />
          <h2>电商后台管理系统</h2>
        </div>
        <!-- 头部右侧 -->
        <div>
          <el-button type="info">退出登陆</el-button>
        </div>
      </el-header>
      <el-container>
        <menua :menu="menu" />
        <el-main id="main">
          <div class="luyou">
            <router-view></router-view>
          </div>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import menua from "@/views/index/components/menu";
import { menus } from "@/http/http.js";
export default {
  name: "",
  components: {
    menua,
  },
  props: [],
  data() {
    return {
      menu: [],
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {
    this.menus();

    this.getheight();
    // 监听页面变化修改高度
    window.addEventListener("resice", this.getheight);
  },
  methods: {
    //  设置导航栏高度
    getheight() {
      let html = document.documentElement || document.body;
      let height = html.clientHeight;
      aside.style.height = height - 60 + "px";
      main.style.height = height - 60 + "px";
    },
    // 获取侧边栏数据
    async menus() {
      const { data: res } = await menus();
      this.menu=res.data
    },
  },
};
</script>

<style lang='scss' scoped>
// 头部
.el-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  background-color: #373d41;
  //   头部左边
  .header-left {
    height: 60px;
    color: white;
    display: flex;
    align-items: center;
    img {
      padding-right: 20px;
    }
  }
}
// 左侧导航
.el-aside {
  background-color: #333744;
}
// 主要区域
.el-main {
  background-color: #eaedf1;
}
.el-container {
  background-color: #333744;
}
.luyou {
  background-color: #fff;
  padding: 20px;
  margin-top: 20px;
}
</style>
